home *** CD-ROM | disk | FTP | other *** search
- property refreshInterval : 12.5
- property maxDuration : 200
- property range : 0
- property maxTrials : 60
-
- property m : 0 --stimulus value is m
- property r : 0 --observer response is r
-
- property prob : {}
- property plgit : {}
- property mlgit : {}
-
- set range to maxDuration div refreshInterval
- set STD to range / 5
-
-
- repeat with i from 1 to 2 * range -- + 1?
- set end of prob to 0 --initialize prob array to 0
- set lgit to 0.5 + 0.5 / (1 + (exponential of ((range - 1) / STD)))
- set end of plgit to natural logarithm of (lgit)
- set end of mlgit to natural logarithm of (1 - lgit)
- end repeat
-
- set m to 1 -- set m to range
- set r to -1 -- set r to 1
- set m to my threshold(r)
- set m to 1 -- set m to range
- set r to 1 -- set r to -1
-
- --main
- repeat with n from 1 to maxTrials
- my threshold(r)
- display dialog ("stimulus presented at " & m) default answer r
- set r to text returned of result
- end repeat
-
- to threshold(response)
- --p1 points to the maximum value of the probability array
- --p2 this is used if teh prob array has a flat peak at max
- --In this case the next value is delivered at the average of this flat region (p1+p2)/2
- --update probabilities based on whether the response was correct
- set max to -10000
- if r = 1 then
- repeat with i from 1 to range
- set itemI to (a reference to item i of prob)
- set itemI to (itemI + (item (range + m - i) of plgit))
- --set p1 to max value of array
- if (itemI > max) then
- set max to contents of itemI
- set p1 to i
- set p2 to i
- else if (itemI = max) then
- set p2 to i
- end if
- end repeat
- else --error
- repeat with i from 1 to range
- set itemI to (a reference to item i of prob)
- set itemI to (itemI + (item (range + m - i) of mlgit))
- --set p1 to max value of array
- if (itemI > max) then
- set max to contents of itemI
- set p1 to i
- set p2 to i
- else if (itemI = max) then
- set p2 to i
- end if
- end repeat
- end if
- set m to round ((p1 + p2) / 2) --update the next test value
- end threshold
-